import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_eve_plugin/pages/main/main.dart';
import 'package:flutter_eve_plugin/store/reducers.dart';
import 'package:flutter_eve_plugin/utils/print_util.dart';
import 'package:logging/logging.dart';
import 'package:redux/redux.dart';
import 'package:redux_thunk/redux_thunk.dart';
import 'package:redux_logging/redux_logging.dart';
import 'package:flutter_eve_plugin/store/main.dart';

void main() {
  final logger = Logger("Redux Logger");

  final store = Store<AppState>(
    appReducer,
    middleware: [
      thunkMiddleware,
      LoggingMiddleware(
          logger: logger, formatter: LoggingMiddleware.multiLineFormatter),
    ],
    initialState: AppState.initialState(),
  );

  logger.onRecord.where((record) => record.loggerName == logger.name).listen(
      (loggingMiddlewareRecord) =>
          logDebugPrint(loggingMiddlewareRecord?.toString()));

  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      systemNavigationBarColor: Colors.transparent,
      systemNavigationBarDividerColor: Colors.transparent));

  runApp(App(store: store, route: window.defaultRouteName));
}
